TARGET = arm-none-eabi
MYARM_ROOT = .

AS = $(TARGET)-as
CC = $(TARGET)-gcc

ARCH = armv6
CFLAGS += -march=$(ARCH) -I$(MYARM_ROOT)/lib

ifdef PROGRAM
all: $(PROGRAM).bin
$(PROGRAM).o: $(MYARM_ROOT)/myarm.ld $(OBJECTS)
	$(CC) -o $@ -T $^ -nostdlib -Wl,--build-id=none -L$(MYARM_ROOT)/lib -lmyarm -lgcc
endif

%.bin: %.o
	$(TARGET)-objcopy -O binary -j .text -j .rodata -j .data $< $@
#%-dram.bin: %.o
#	$(TARGET)-objcopy -O binary -j .dram.text -j .dram.rodata -j .dram.data $< $@
%.dis: %.o
	$(TARGET)-objdump -d $< > $@

clean:
	rm -f *.o *.bin *.dis

.PHONY: all clean
.PRECIOUS: %.o
